<?php
namespace app\mini\controller\v1\client;
use app\common\logic\CollectionLogic;
use app\common\logic\CouponLogic;
use app\common\logic\UsedCarLogic;
use app\common\model\Config;
use app\mini\controller\Common;
use think\Exception;
use think\Request;
use think\response\Json;

class Collection extends Common
{
    public $CollectionLogic;
    public $UsedCarLogic;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->CollectionLogic = new CollectionLogic();
        $this->UsedCarLogic = new UsedCarLogic();
    }

    /**
     * 收藏类目
     * @return Json
     */
    public function types()
    {
        $res = $this->exception(function () {
            return $this->CollectionLogic->types();
        });
        return $this->response($res);
    }

    /**
     * 收藏洗车列表
     * @return Json
     */
    public function xiche()
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['type'] = 0;
            return $this->CollectionLogic->xiche($params);
        });
        return $this->response($res);
    }

    /**
     * 收藏二手车列表
     * @return Json
     */
    public function used_car()
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['type'] = 1;
            return $this->CollectionLogic->used_car($params);
        });
        return $this->response($res);
    }


    /**
     * 收藏商机列表
     * @return Json
     */
    public function service()
    {
        $res = $this->exception(function () {
            $params = request()->param();
            return $this->CollectionLogic->service($params);
        });
        return $this->response($res);
    }


    /**
     * 新增
     * @return array
     */
    public function add(): Json
    {
        $res = $this->exception(function () {
            return $this->CollectionLogic->add(request()->param());
        });
        return $this->response($res);
    }

    /**
     * 删除
     * @return array
     */
    public function del(): Json
    {
        $res = $this->exception(function () {
            return $this->CollectionLogic->del(request()->param());
        });
        return $this->response($res);
    }

}